/**
* 初始化页面
*/
var roleModuleTree = null;
function initPage(){
    win.crebtn('addRole_btnCancel', '关闭', win.close);
    win.crebtn('addRole_btnSave', '保存', addRoleModule);
    getModuleTreeByRoleDM();
}
function getModuleTreeByRoleDM(){
    var json = {
        url:contextPath + "/server/sys/getModuleTreeByRoleDM.do",
        msg:"数据加载中.....",
        params:{
            "MODULE_DM_SJ":"1",
            "ROLE_DM":myTools.getQueryString("ROLE_DM"),
            "USER_DM":window.parent.parent.parent.parent.session.USER_DM
        },
        callback:[getModuleTreeByRoleDMCallBack]
    };
    AjaxTools.ajax(json);
}
function getModuleTreeByRoleDMCallBack(data) {
        roleModuleTree = new dhtmlXTreeObject(document.getElementById('treeBox'), "100%", "100%", 0);
        roleModuleTree.setImagePath("../../include/js/components/xTree/xTree_imgs/csh_bluebooks/");
        roleModuleTree.enableCheckBoxes(true);
        roleModuleTree.enableThreeStateCheckboxes(true);
        roleModuleTree.loadXMLString(data.data);
        roleModuleTree.closeAllItems(0);
}
/**
 *添加角色
 */
function addRoleModule() {
    var json = {
        url:contextPath + "/server/sys/insertRoleModule.do",
        msg:"数据保存中.....",
        params:{
            "MODULE_DMS":roleModuleTree.getAllCheckedBranches(),
            "ROLE_DM":myTools.getQueryString("ROLE_DM")
        },
        callback:[addRoleModuleCallBack]
    };
    AjaxTools.ajax(json);
}
function addRoleModuleCallBack(data) {
    var code = data.code;
    if (code == "00") {
        alert(data.data);
        window.parent.parent.getRole();
        win.close('addRole');
    } else {
        alert(data.data);
    }

}